<link rel="stylesheet" href="{{asset(env('CDN_HOST').'/public/css/cart/footer.css')}}">
<div id="cart-footer" class="cart-footer">
    <div class="cft-left">
        <span class="cft-select">
            <span class="cft-select-circle">
                <span class="footer-circle cft-circle"></span>
            </span>
            <span class="cft-select-txt">
                已选(<span class="cft-cart-num">0</span>)
            </span>
        </span>
        <span class="cft-price">
            ￥<span class="cft-cart-price">0</span>
        </span>
    </div>
    <div class="cft-right">
        下单
    </div>
</div>
<script>
    $(".footer-circle").on("click", function () {
        if ($(this).hasClass("cft-circle")) {
            $(this).removeClass("cft-circle")
            $(this).addClass("cft-circle-active")
            $(".list-circle").removeClass("circle");
            $(".list-circle").addClass("circle-active");
        } else {
            $(this).removeClass("cft-circle-active")
            $(this).addClass("cft-circle")
            $(".list-circle").removeClass("circle-active");
            $(".list-circle").addClass("circle");
        }
        change_cart_info()
    })
    $(".cft-right").on("click", function () {
        $cart_active = $(".circle-active")
        if ($cart_active.length == 0 || $cart_active.length < 1) {
            alert("请选择商品")
            return false
        }
        loading.show()
        var data = {}
        for (var i = 0; i < $cart_active.length; i++) {
            var $parent = $cart_active.eq(i).parents('.list-box')
            var key = "cart" + $parent.attr("data-cart-id")
            if (typeof cart[key] == "undefined")
                continue
            data[i] = cart[key].cart
        }
        data["_token"] = csrf_token
        console.table(data);
        $.post("/api/set_cart_session", data, function (e) {
            if (e.errorCode == 0) {
                window.location.href = "/cart/right"
            } else {
                loading.hide()
                alert(e.errorMsg)
            }
        })
    })
</script>